package com.sk.places.places2.service.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="T_PLACE_TYPE")
public class PlaceType implements Serializable{


	private static final long serialVersionUID = 1L;
	@Id
	private Long id;
	@Column(name="PLACE_TYPE")
	private String placeType ;
	
	@ManyToMany
	@JoinTable(name="T_PLACE_PLACE_TYPE", 
	joinColumns=@JoinColumn(name="PLACE_TYPE_ID",referencedColumnName="ID"), 
		  inverseJoinColumns=@JoinColumn(name="PLACE_ID" , referencedColumnName="ID"))
	private List<Place> places; 
	
	public List<Place> getPlaces() {
		return places;
	}
	public void setPlaces(List<Place> places) {
		this.places = places;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getPlaceType() {
		return placeType;
	}
	public void setPlaceType(String placeType) {
		this.placeType = placeType;
	}
	
	public boolean equals(Object obj){
		if(obj instanceof PlaceType){
			PlaceType placeType = (PlaceType)obj;
			if(this.id==placeType.id && this.placeType.equals(((PlaceType) obj).placeType)){
				return true;
			}
		}
		return false;
	}
}
